package com.abc.cloud.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.abc.cloud.entity.RoleMenuRelationEntity;
import com.abc.cloud.service.RoleMenuRelationService;
import com.abc.cloud.common.utils.PageUtil;
import com.abc.cloud.common.utils.Result;



/**
 * 角色菜单关联表
 *
 * @author LiJunXi
 * @email 2770063826@qq.com
 * @date 2023-10-27 13:09:54
 */
@RestController
@RequestMapping("cloud/rolemenurelation")
public class RoleMenuRelationController {
    @Autowired
    private RoleMenuRelationService roleMenuRelationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Result list(@RequestParam Map<String, Object> params){
        PageUtil page = roleMenuRelationService.queryPage(params);

        return Result.success(page, "page");
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{roleId}")
    public Result info(@PathVariable("roleId") Long roleId){
		RoleMenuRelationEntity roleMenuRelation = roleMenuRelationService.getById(roleId);

        return Result.success(roleMenuRelation, "roleMenuRelation");
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Result save(@RequestBody RoleMenuRelationEntity roleMenuRelation){
		roleMenuRelationService.save(roleMenuRelation);

        return Result.success(null, "");
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody RoleMenuRelationEntity roleMenuRelation){
		roleMenuRelationService.updateById(roleMenuRelation);

        return Result.success(null, "");
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public Result delete(@RequestBody Long[] roleIds){
		roleMenuRelationService.removeByIds(Arrays.asList(roleIds));

        return Result.success(null, "");
    }

}
